import 'package:rc_app/bean/user_entity.dart';
import 'package:rc_app/contants/constant.dart';
import 'package:rc_app/http/mock_request.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'API.dart';
import 'http_request.dart';

/**
 * 警情api
 */
typedef RequestCallBack<T> = void Function(T value);
class AlarmApi{
  Future getAlarmList(int page,RequestCallBack callBack) async {
    var _request;
    SharedPreferences prefs = await SharedPreferences.getInstance();
    bool useNetData = prefs.getBool(Constant.USE_NET_DATA) ?? false;
    if(useNetData){
      _request  = HttpRequest(API.BASE_URL);
    }else {
      _request = new  MockRequest();
    }
    var result = await _request.get(API.ALARM_LIST);
    callBack(result);
  }
}